/*获取所有审核订单*/
function getOrders(){
	$.ajax({
		type:"post",
		url:"checkOrder",
		success:function(result){
			for(var i=0;i<result.resultParm.orders.length;i++){
				if(result.resultParm.orders[i].status==0);
				{
					var time = result.resultParm.orders[i].orderTime;
					var myDate = new Date(time);
					var year=myDate.getFullYear();
					//获取当前月
					var month=myDate.getMonth()+1;
					//获取当前日
					var date=myDate.getDate(); 
					var h=myDate.getHours();       //获取当前小时数(0-23)
					var m=myDate.getMinutes();     //获取当前分钟数(0-59)
					var s=myDate.getSeconds();  
					/*获得当前时间*/
					function p(s) {
					    return s < 10 ? '0' + s: s;
					};
					//格式
					var now=year+'-'+p(month)+"-"+p(date)+" "+p(h)+':'+p(m)+":"+p(s);
					
					var newLine = 
					"<tr>"+
						"<td>"+result.resultParm.orders[i].id+"</td>"+
						"<td>"+result.resultParm.orders[i].equipment.name+"</td>"+
						"<td>"+result.resultParm.orders[i].number+"</td>"+
						"<td>"+now+"</td>"+
						"<td>"+result.resultParm.orders[i].borrowAccount+"</td>"+
						"<td>"+result.resultParm.orders[i].borrowName+"</td>"+
						"<td>"+result.resultParm.orders[i].telephone+"</td>"+
						"<td>"+"<a title="+"\"checkA\""+ "href="+"#"+">审核通过</a>"+"</td>"
					"</tr>";
				$("table").append(newLine);
				};
			};
			checkA();
		},
		error:function(){
			alert('获取列表失败');
		}
});
};

/*审核通过超链接*/
function checkA(){
	$("a[title=checkA]").click(function(){
		var r=confirm("确认通过审核么？");
		if(r==true){
			$.ajax({
			type:"post",
			url:"checkedOrder",
			data:{
				id:$(this).parent().parent().children().eq(0).text(),
			},
			success:function(result){
			 	alert(result.resultInfo);
			 	$(".eq-table table tr td").remove();
			 	getOrders();
			},
			error:function(){
				alert("审核失败");
			}
		});
		}
	});
};

/*进入页面获取所有订单信息*/
getOrders();

